Make it possible for theme engines to support symbolic colors. (#426192,
authorMatthias Clasen <mclasen@redhat.com>
Fri, 8 Jun 2007 05:02:13 +0000 (05:02 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 8 Jun 2007 05:02:13 +0000 (05:02 +0000)
2007-06-08  Matthias Clasen  <mclasen@redhat.com>

        Make it possible for theme engines to support symbolic
        colors.  (#426192, Andrea Cimitan, patch by Olivier Samyn)

        * gtk/gtk.symbols:
        * gtk/gtkrc.h:
        * gtk/gtkrc.c (gtk_rc_parse_color_full): Export this function

        * gtk/gtkrc.c (gtk_rc_parse_engine): Copy color hashes
        to new style before parsing engine section.

svn path=/trunk/; revision=18081

ChangeLog
docs/reference/ChangeLog
docs/reference/gtk/gtk-sections.txt
gtk/gtk.symbols
gtk/gtkrc.c
gtk/gtkrc.h

index 2d52f33ea48731b3deafffabf0673c8f5295318a..1999228e0031aae3c554d774bc06a6cb39709110 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2007-06-08  Matthias Clasen  <mclasen@redhat.com>
+
+       Make it possible for theme engines to support symbolic 
+       colors.  (#426192, Andrea Cimitan, patch by Olivier Samyn)
+
+       * gtk/gtk.symbols:
+       * gtk/gtkrc.h:
+       * gtk/gtkrc.c (gtk_rc_parse_color_full): Export this function
+
+       * gtk/gtkrc.c (gtk_rc_parse_engine): Copy color hashes
+       to new style before parsing engine section.
+
 2007-06-08  Michael Natterer  <mitch@imendio.com>
 
        * gdk/quartz/gdkdrawable-quartz.c: add utility function
index 8ba947374321d079b14ca95340d0720ecdc65560..5772e19019ce9355ce31873e8403276aaf7e2475 100644 (file)
@@ -1,3 +1,7 @@
+2007-06-08  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtk-sections.txt: Add gtk_rc_parse_color_full
+
 2007-06-06  Matthias Clasen  <mclasen@redhat.com>
 
        * === Released 2.11.2 ===
index 4cdb79f7a1b4ae2a975eb40b23b253bed4e1e598..9da0b3bfb81fdc9e8125653462dd73999294afed 100644 (file)
@@ -5563,6 +5563,7 @@ gtk_rc_add_default_file
 gtk_rc_get_default_files
 gtk_rc_set_default_files
 gtk_rc_parse_color
+gtk_rc_parse_color_full
 gtk_rc_parse_state
 gtk_rc_parse_priority
 gtk_rc_find_module_in_path
index 69694376fa45e779d9bb8a912ef6c591c294952b..5355e255922197d762c7e5a0b3b4d6a5e032516b 100644 (file)
@@ -3041,6 +3041,7 @@ gtk_rc_parse PRIVATE
 gtk_rc_parse_utf8
 #endif
 gtk_rc_parse_color
+gtk_rc_parse_color_full
 gtk_rc_parse_priority
 gtk_rc_parse_state
 gtk_rc_parse_string
index 324b37a49ba01a5102a2efec7e9886419f39d379..ae5cdd5239c2cf48eb23b58bb043cb5076130812 100644 (file)
@@ -218,9 +218,6 @@ static guint       gtk_rc_parse_stock                (GtkRcContext    *context,
 static guint       gtk_rc_parse_logical_color        (GScanner        *scanner,
                                                       GtkRcStyle      *rc_style,
                                                       GHashTable      *hash);
-static guint       gtk_rc_parse_color_full           (GScanner        *scanner,
-                                                      GtkRcStyle      *style,
-                                                      GdkColor        *color);
 
 static void        gtk_rc_clear_hash_node            (gpointer         key,
                                                       gpointer         data,
@@ -1550,9 +1547,8 @@ gtk_rc_style_copy_icons_and_colors (GtkRcStyle   *rc_style,
     {
       gtk_rc_style_prepend_empty_color_hash (rc_style);
 
-      priv->color_hashes =
-        g_slist_append (priv->color_hashes,
-                        g_hash_table_ref (context->color_hash));
+      priv->color_hashes = g_slist_append (priv->color_hashes,
+                                           g_hash_table_ref (context->color_hash));
     }
 }
 
@@ -3605,6 +3601,7 @@ gtk_rc_parse_engine (GtkRcContext *context,
   guint result = G_TOKEN_NONE;
   GtkRcStyle *new_style = NULL;
   gboolean parsed_curlies = FALSE;
+  GtkRcStylePrivate *rc_priv, *new_priv;
   
   token = g_scanner_get_next_token (scanner);
   if (token != GTK_RC_TOKEN_ENGINE)
@@ -3628,13 +3625,23 @@ gtk_rc_parse_engine (GtkRcContext *context,
 
       parsed_curlies = TRUE;
 
+      rc_priv = GTK_RC_STYLE_GET_PRIVATE (*rc_style);
+
       if (G_OBJECT_TYPE (*rc_style) != GTK_TYPE_RC_STYLE)
        {
          new_style = gtk_rc_style_new ();
          gtk_rc_style_real_merge (new_style, *rc_style);
-         
-         if ((*rc_style)->name)
-           new_style->name = g_strdup ((*rc_style)->name);
+
+          new_style->name = g_strdup ((*rc_style)->name);
+
+          /* take over icon factories and color hashes 
+           * from the to-be-deleted style
+           */
+          new_style->icon_factories = (*rc_style)->icon_factories;
+          (*rc_style)->icon_factories = NULL;
+          new_priv = GTK_RC_STYLE_GET_PRIVATE (new_style);
+          new_priv->color_hashes = rc_priv->color_hashes;
+          rc_priv->color_hashes = NULL;
        }
       else
        (*rc_style)->engine_specified = TRUE;
@@ -3655,10 +3662,19 @@ gtk_rc_parse_engine (GtkRcContext *context,
          g_type_module_unuse (G_TYPE_MODULE (engine));
          
          new_class = GTK_RC_STYLE_GET_CLASS (new_style);
-         
+
          new_class->merge (new_style, *rc_style);
-         if ((*rc_style)->name)
-           new_style->name = g_strdup ((*rc_style)->name);
+
+          new_style->name = g_strdup ((*rc_style)->name);
+
+          /* take over icon factories and color hashes 
+           * from the to-be-deleted style
+           */
+          new_style->icon_factories = (*rc_style)->icon_factories;
+          (*rc_style)->icon_factories = NULL;
+          new_priv = GTK_RC_STYLE_GET_PRIVATE (new_style);
+          new_priv->color_hashes = rc_priv->color_hashes;
+          rc_priv->color_hashes = NULL;
          
          if (new_class->parse)
            {
@@ -3667,6 +3683,13 @@ gtk_rc_parse_engine (GtkRcContext *context,
              
              if (result != G_TOKEN_NONE)
                {
+                  /* copy icon factories and color hashes back
+                   */
+                  (*rc_style)->icon_factories = new_style->icon_factories;
+                  new_style->icon_factories = NULL;
+                  rc_priv->color_hashes = new_priv->color_hashes;
+                  new_priv->color_hashes = NULL;
+
                  g_object_unref (new_style);
                  new_style = NULL;
                }
@@ -3698,18 +3721,6 @@ gtk_rc_parse_engine (GtkRcContext *context,
 
   if (new_style)
     {
-      GtkRcStylePrivate *rc_priv = GTK_RC_STYLE_GET_PRIVATE (*rc_style);
-      GtkRcStylePrivate *new_priv = GTK_RC_STYLE_GET_PRIVATE (new_style);
-
-      /* take over icon factories and color hashes from the to-be-deleted style
-       */
-
-      new_style->icon_factories = (*rc_style)->icon_factories;
-      (*rc_style)->icon_factories = NULL;
-
-      new_priv->color_hashes = rc_priv->color_hashes;
-      rc_priv->color_hashes = NULL;
-
       new_style->engine_specified = TRUE;
 
       g_object_unref (*rc_style);
@@ -3820,6 +3831,20 @@ gtk_rc_parse_priority (GScanner             *scanner,
   return G_TOKEN_NONE;
 }
 
+/**
+ * gtk_rc_parse_color:
+ * @scanner: a #GScanner
+ * @color: a pointer to a #GtkColor structure in which to store the result
+ *
+ * Parses a color in the <link linkend="color=format">format</link> expected
+ * in a RC file. 
+ *
+ * Note that theme engines should use gtk_rc_parse_color_full() in 
+ * order to support symbolic colors.
+ *
+ * Returns: %G_TOKEN_NONE if parsing succeeded, otherwise the token
+ *     that was expected but not found
+ */
 guint
 gtk_rc_parse_color (GScanner *scanner,
                    GdkColor *color)
@@ -3827,7 +3852,22 @@ gtk_rc_parse_color (GScanner *scanner,
   return gtk_rc_parse_color_full (scanner, NULL, color);
 }
 
-static guint
+/**
+ * gtk_rc_parse_color_full:
+ * @scanner: a #GScanner
+ * @style: a #GtkRcStyle, or %NULL
+ * @color: a pointer to a #GtkColor structure in which to store the result
+ *
+ * Parses a color in the <link linkend="color=format">format</link> expected
+ * in a RC file. If @style is not %NULL, it will be consulted to resolve
+ * references to symbolic colors.
+ *
+ * Returns: %G_TOKEN_NONE if parsing succeeded, otherwise the token
+ *     that was expected but not found
+ *
+ * Since: 2.12
+ */
+guint
 gtk_rc_parse_color_full (GScanner   *scanner,
                          GtkRcStyle *style,
                          GdkColor   *color)
index a64343c45ef4e54f475a6672945f6892e1166721..c6880af272ed81d62da8301beefff31b4ae432bb 100644 (file)
@@ -102,7 +102,7 @@ struct _GtkRcStyleClass
                       GtkSettings  *settings,
                       GScanner     *scanner);
   
-  /* Combine RC style data from src into dest. If overriden, this
+  /* Combine RC style data from src into dest. If overridden, this
    * function should chain to the parent.
    */
   void      (*merge)  (GtkRcStyle *dest,
@@ -227,6 +227,9 @@ typedef enum {
 GScanner* gtk_rc_scanner_new   (void);
 guint    gtk_rc_parse_color    (GScanner            *scanner,
                                 GdkColor            *color);
+guint    gtk_rc_parse_color_full (GScanner          *scanner,
+                                   GtkRcStyle        *style,
+                                  GdkColor          *color);
 guint    gtk_rc_parse_state    (GScanner            *scanner,
                                 GtkStateType        *state);
 guint    gtk_rc_parse_priority (GScanner            *scanner,